![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@rest-hooks/endpoint
Advanced tools
Declarative, strongly typed, reusable network definitions for networking libraries.
import { Endpoint } from '@rest-hooks/endpoint';
const fetchUser = ({ id }) ⇒ fetch(`/users/${id}`).then(res => res.json());
const UserDetail = new Endpoint(fetchUser);
function UserProfile() {
const user = useResource(UserDetail, { id });
const updateUser = useFetcher(UserDetail);
return <UserForm user={user} onSubmit={updateUser} />
}
const user = await UserDetail({ id: '5' });
console.log(user);
There is a distinction between
Thus, there are many benefits to creating a distinct seperation of concerns between these two concepts.
With TypeScript Standard Endpoints
, we define a standard for declaring in
TypeScript the definition of a networking API.
@rest-hooks/endpoint
defines a standard interface
interface EndpointInterface {
(params?: any, body?: any): Promise<any>;
key(parmas?: any): string;
schema?: Readonly<S>;
sideEffects?: true;
// other optionals like 'optimistic'
}
as well as a helper class
to make construction easier.
class Endpoint<F extends () => Promise<any>> {
constructor(fetchFunction: F, options: EndpointOptions);
key(...args: Parameters<F>): string;
readonly sideEffect?: true;
readonly schema?: Schema;
fetch: F;
extend(options: EndpointOptions): Endpoint;
}
export interface EndpointOptions extends EndpointExtraOptions {
key?: (params: any) => string;
sideEffect?: true | undefined;
schema?: Schema;
}
Serializes the parameters. This is used to build a lookup key in global stores.
Default:
`${this.fetch.name} ${JSON.stringify(params)}`
Disallows usage in hooks like useResource()
since they might call fetch
an unpredictable number of times. Use this for APIs with mutation side-effects like update, create, deletes.
Defaults to undefined meaning no side effects.
Declarative definition of where Entities
appear in the fetch response.
Not providing this option means no entities will be extracted.
import { Entity } from '@rest-hooks/normalizr';
import { Endpoint } from '@rest-hooks/endpoint';
class User extends Entity {
readonly id: string = '';
readonly username: string = '';
pk() { return this.id;}
}
const UserDetail = new Endpoint(
({ id }) ⇒ fetch(`/users/${id}`),
{ schema: User }
);
Can be used to further customize the endpoint definition
const UserDetail = new Endpoint(({ id }) ⇒ fetch(`/users/${id}`));
const UserDetailNormalized = UserDetail.extend({ schema: User });
export interface IndexInterface<S extends typeof Entity> {
key(parmas?: Readonly<IndexParams<S>>): string;
readonly schema: S;
}
import { Entity } from '@rest-hooks/normalizr';
import { Index } from '@rest-hooks/endpoint';
class User extends Entity {
readonly id: string = '';
readonly username: string = '';
pk() { return this.id;}
static indexes = ['username'] as const;
}
const UserIndex = new Index(User)
const bob = useCache(UserIndex, { username: 'bob' });
// @ts-expect-error Indexes don't fetch, they just retrieve already existing data
const bob = useResource(UserIndex, { username: 'bob' });
FAQs
Declarative Network Interface Definitions
The npm package @rest-hooks/endpoint receives a total of 1,055 weekly downloads. As such, @rest-hooks/endpoint popularity was classified as popular.
We found that @rest-hooks/endpoint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.